package com.yunji.common.enums.business;

import com.yunji.common.utils.bean.BeanUtils;
import lombok.Getter;

import java.util.Objects;

/**
 * @Project: yunji-coffee
 * @Package: com.yunji.order.emuns
 * @Title: TradeTypes
 * @Description: 交易类型
 * <p>
 * History:
 * Date                     Version     Author          Summary
 * ============================================================
 * 2024-04-10 17:31:47      V1.0        HuaAo       新建类
 */

@Getter
public enum TradeTypes {
    NOT_EXISTS(-1, "无",-1),
    PRODUCT_BUYING(11, "商品购买", 14),
    PURSE_RECHARGE(12, "钱包充值", -12),
    PURSE_PAYOUTS(13, "钱包提现", -13),
    PRODUCT_BUYING_REFUND(14, "商品购买退款", -1),
    PLATE(21, "平台收益", 24),
    STAFF_SCALE(22, "员工分成", 25),
    AGENT_SCALE(23, "商品收益", 26),
    SITE_SCALE(27, "网点分成", 28),
    PLATE_REFUND(24, "平台收益退款", -1),
    STAFF_SCALE_REFUND(25, "员工分成退款", -1),
    AGENT_SCALE_REFUND(26, "商品收益退款", -1),
    SITE_SCALE_REFUND(28, "网点分成退款", -1);
    private final Integer code;
    private final String text;
    private final Integer refundCode;


    TradeTypes(Integer code, String text, Integer refundCode) {
        this.code = code;
        this.text = text;
        this.refundCode = refundCode;
    }

    public static TradeTypes get(Integer code) {
        if (BeanUtils.isNull(code)) {
            return null;
        }
        TradeTypes[] enums = TradeTypes.values();
        for (TradeTypes e : enums) {
            if (Objects.equals(e.code, code)) {
                return e;
            }
        }
        return TradeTypes.NOT_EXISTS;
    }
}
